<div class="service-popup">
	<h3 class="popup-title">Записаться в сервис центр</h3>
	<div class="service-popup__form">
		<?php
		$form = $this->beginWidget('CActiveForm', array(
			'id' => 'buying-form-99',
			'action' => '/main/ajax/contactJoin',
			'enableClientValidation' => true,
			'htmlOptions'=>array('class'=>'form'),
			'clientOptions' => array(
				'validateOnSubmit' => true,
			),
		));
		?>
		<div style="display: none">
			<?php echo $form->error($model, 'userName'); ?>
			<?php echo $form->error($model, 'userPhone'); ?>
		</div>		
		<fieldset>
			<div class="type-text">
				<?php echo $form->textField($model, 'userName', array('placeholder' => 'Ваше имя')); ?>	
			</div>
		</fieldset>
		<fieldset>
			<div class="type-text">
				<?php echo $form->textField($model, 'userPhone', array('placeholder' => 'Ваш телефон', 'class' => 'masked-phone')); ?>
			</div>
		</fieldset>
		<fieldset>
			<div class="type-submit">
				<?php echo CHtml::submitButton('Отправить'); ?>				
			</div> 
		</fieldset>
		<?php $this->endWidget(); ?>
		<p>Мы с вами свяжемся, в течение 15 рабочих минут.</p>
	</div>	
</div>
<script type="text/javascript">
	/*&lt;![CDATA[*/
	jQuery("#ContactJoinForm_userPhone").mask("+7 (999) 999-99-99");
	jQuery('#buying-form-99').yiiactiveform({'validateOnSubmit': true,
		'afterValidate':
				function(form, data, hasError) {
					if (!hasError) {
						$.ajax({
							type: "POST",
							url: form[0].action,
							data: $(form).serialize(),
							success: function(ret) {
								$('.fancybox-close').trigger('click');
								var data = JSON.parse(ret);								
								mobi03.showMessage(data.message.title, data.message.desc);
							}
						});
					}
				}
		, 'attributes': [{'id': 'ContactJoinForm_userName', 'inputID': 'ContactJoinForm_userName', 'errorID': 'ContactJoinForm_userName_em_', 'model': 'ContactJoinForm', 'name': 'userName', 'enableAjaxValidation': false, 'clientValidation': function(value, messages, attribute) {

					if (jQuery.trim(value) == '') {
						messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Name\u00bb.");
					}

				}}, {'id': 'ContactJoinForm_userPhone', 'inputID': 'ContactJoinForm_userPhone', 'errorID': 'ContactJoinForm_userPhone_em_', 'model': 'ContactJoinForm', 'name': 'userPhone', 'enableAjaxValidation': false, 'clientValidation': function(value, messages, attribute) {

					if (jQuery.trim(value) == '') {
						messages.push("\u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u00abUser Phone\u00bb.");
					}

				}}], 'errorCss': 'error'});
                    $('#buying-form-99').attr('action', $('#buying-form-99').attr('action') + '?url=http://' + location.hostname + location.pathname);
	/*]]&gt;*/
</script>